home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / knowhow4 / vector.cpp < prev    next >
C/C++ Source or Header  |  1994-11-05  |  7KB  |  178 lines

  1. #include "vector.h"
  2.  
  3. int application(int) { return 0; }  // dummy function - will not be in use
  4. rect r_draw_size;      // == bound of draw object, expanded or not
  5.  
  6. Vector::Vector(char* fileName, char* bufName, int obj_num, int step)
  7.     : ApplicationKit(step, loc(39, 13))
  8.     {
  9.     set_object_number(obj_num);
  10.     DATA_FILE = 1;
  11. // constructors for objects
  12.     rect r_base(0, 0, 80, 25);
  13.     w1 = new Window(r_base, fileName, "", 0, BUTTON_BORDER, NO_BORDER,
  14.            MOVE | RESIZE, 0, 0);
  15. //////////////////////////////
  16.     rect r_vector(0, 2, 40, 25);
  17.     vector = new KH_OOPic(r_vector, "vector.pcy", NO_BORDER);
  18. //////////////////////////////
  19.     rect ok_rect(0,0,5,2);
  20.     OK_button = new Button(ok_rect, " OK ");
  21. //////////////////////////////
  22.     rect r_menu(5, 0, 70, 2);
  23.     static char* hotMenuList = "FBSP";       // hot for line menu
  24.     static char* menuList[] = { " File ", " Buffer ",
  25.     " Script ", " Print ", "" };
  26.     menu = new
  27.     BlockLineMenu(r_menu, "", hotMenuList, menuList, rect(0, 24, 79, 25),
  28.            0, NULL, NULL, BUTTON_BORDER, 16, 16, 16);
  29. ////////////////////////////////
  30. // To be used with MOVE / RESIZE facilities
  31. //    rect r_resize_panel(0, 0, 5, 3);
  32. //    static int ic_resize_list[] = { I_MOVE, I_RESIZE, 0 };
  33. //    loc l = pScreenSet->g_mode == VGAHI ? loc(4, 4) : loc(4, 2);
  34. //    resize_panel = new IconMenu(r_resize_panel, "", "",
  35. //              NULL, 1, 1, SMALL_ICON, ic_resize_list, l,
  36. //              rect(0, 0, 25, 80), 0, NULL, NULL, FIXED, 0,
  37. //              BUTTON_BORDER, NO_BORDER);
  38. ////////////////////////////////
  39. /*    rect r_script_edit(10, 5, 70, 20);                 // Editor
  40.     script_editor = new
  41.     BlockWrite(r_script_edit, "", "work.txt", "Editor", 6,
  42.         MOVE | RESIZE, SHOW_BORDER, SHOW_BORDER, SHOW_BORDER,
  43.         0, 0, 0, 16);
  44. */
  45. //////////////////////////
  46.     rect r_edit(40, 2, 80, 25);                 // Editor
  47.     editor = new Write(r_edit, "work.vec", "", "Interpreter", 6,
  48.         SHOW_BORDER, SHOW_BORDER, 0, 0);
  49. //////////////////////////
  50.     rect r_file = rect(5, 3, 33, 16);
  51.     static char* hotFileList = "COSAB";             // hot for file menu
  52.     static char* fileList[] = { " Clear ", " Open ",
  53.     " Save", " save As pcx", "save aS pcx B&w",
  54.     " << ? >> ", "" };
  55.  
  56.     file_menu = new BlockMenu(r_file, "", " Files ", 6, hotFileList,
  57.     fileList, rect(0, 24, 79, 25), 0, NULL, NULL,
  58.            FIXED, SHOW_BORDER, SHOW_BORDER, 16, 16, 16, 16);
  59. ///////////////////////////
  60.     file_sys = new BlockFile("File");
  61. //////////////////////////
  62.     rect r_script = rect(50, 4, 69, 14);
  63.     static char* items_script[] = { " Go ", " Record ", " Stop ", " Macros ",
  64.     /*" Text ",*/ "" };
  65.     static char* hotScriptList = "GRSMT";         // for script menu
  66.     script_menu = new BlockMenu(r_script, "", " Scripts ", 6,
  67.     hotScriptList, items_script, rect(0, 24, 79, 25), 0, NULL, NULL,
  68.            FIXED, SHOW_BORDER, SHOW_BORDER, 16, 16, 16, 16);
  69. ///////////////////////////
  70.     r_draw_size = vector->user_screen();//rect(9, 2, 80, 24);    // init value for draw object == r_draw
  71. /////////////////////////////
  72. //    rect r = vector->user_screen();
  73. //    r.corner.Y -= 1;
  74.     buffer = NULL; //new GrafBuffer(loc(750, 550), bufName, r);
  75.     print = new PrintManager(EPSON9, DD, 1, rect(1, 1, 1, 1), 0,
  76.                           PAPER_ON, 6);
  77.     form = new Form();
  78. ///////////
  79.     setup = new BufferSetup();
  80. ///////////
  81. // We add objects to the container "kit".
  82.     background(w1);
  83.     add(menu);
  84.     add(OK_button);
  85.     add(vector);
  86.     add(editor);
  87.  
  88. //    add(resize_panel);    // MOVE and RESIZE the program kit
  89.  
  90.     add(file_menu);       // go here from "menu" FILE
  91.     add(setup);           // go here from "menu" Buffer
  92.     add(script_menu);
  93.     add(form);
  94.  
  95.     add(file_sys);        // go here from "file_menu", "script_menu"...
  96.     add(file_sys);
  97.     add(file_sys);
  98.     add(file_sys);
  99. //    add(script_editor);
  100.  
  101. // We set the numbers (or the names, which may be transformed to number
  102. // of the objects which will be called after exiting from current object
  103. // with ENTER-like command.
  104. //    set_point(fill_prompt, fill_panel);
  105. // we set, that after exiting from object with ENTER-like command it will
  106. // call function N + no of menu choice - 1 from appl1.cpp file,
  107. // and then call object No ... in list. Note that it can overwrite the
  108. // set_point settings.
  109. //    assign(w1, resize_panel, AC_MOVE); // Reserved
  110.  
  111.     assign(file_menu, menu, AC_FILE_MENU);
  112.     assign(file_sys, file_menu, AC_NEW); // ATTENTION!!! OPEN and SAVE
  113.                   // points to the same file_sys object.
  114.     assign(0, OK_button, AC_PROGRAM_SAVE_AND_RUN);
  115.     assign(file_sys, script_menu, AC_SCRIPT_PLAY);
  116.     assign(0, form, AC_PRINT);
  117.     assign(0, file_sys, AC_FILE);
  118. //    assign(0, script_editor, AC_EDITOR);
  119.     assign(0, editor, AC_PROGRAM_RUN);
  120.     assign(editor, vector, AC_PROGRAM_EDIT);
  121.  
  122.     assign(0, setup, AC_BUFFER);
  123.  
  124.     set_exit(AC_ASK_EXIT);
  125.  
  126. // We can set the numbers (or the names, which may be transformed to number
  127. // of the objects which will be called after exiting from current object
  128. // with ESC-like command. If current object was called from another
  129. // object, its callFrom flag will be changed, correspondingly, so it is not
  130. // absolutely necessary : kit->set_call(file_menu, menu)...
  131. // default object hides itself after exiting. But to obtain first-second-third...
  132. // level menu cascade we must change return flag to 2. In this case menu
  133. // will hide itself after exiting with ESC-like command, and will not -
  134. // if the next menu must be called (ENTER command).
  135.     menu->set_ret(RET_CANCEL | RET_STACKED);
  136.     file_menu->set_ret(RET_MOUSE | RET_CANCEL | RET_TRANSFER);
  137.     form->set_ret(RET_MOUSE | RET_CANCEL | RET_OK);
  138.     setup->set_ret(RET_MOUSE | RET_CANCEL | RET_OK);
  139.     script_menu->set_ret(RET_CANCEL | RET_MOUSE | RET_TRANSFER);
  140.     file_sys->set_ret(RET_CANCEL | RET_MOUSE | RET_TRANSFER);
  141. //    script_editor->set_ret(RET_OK | RET_MOUSE | RET_CANCEL);
  142.  
  143.     w1->set_ret(RET_STACKED);
  144. //    resize_panel->set_ret(RET_STACKED);
  145.     editor->set_ret(RET_STACKED);
  146. //    vector->set_ret(RET_STACKED);
  147.  
  148. // Setting of the context help. ATTENTION!!! only ObjectKit childs have help.
  149.     menu->set_help_context("common  ");
  150.     file_menu->set_help_context("file_sys");
  151.     script_menu->set_help_context("script  ");
  152.     form->set_help_context("printset");
  153.     setup->set_help_context("bufsetup");
  154.     }
  155. ///////////////////////////////
  156. Vector::~Vector()
  157.     {
  158.     editor->hide();
  159.     delete print;
  160.     delete buffer;
  161.     }
  162. /////////////////////////
  163. void Vector::show()
  164.     {
  165.     mouseHideCursor();
  166.     WindowManager::show_window(w1);
  167.     WindowManager::show_window(OK_button);
  168.     vector->set_program(vector->load_program("work.vec"));
  169.     WindowManager::show_window(vector);
  170.     WindowManager::show_window(editor);
  171.     WindowManager::show_window(menu);
  172. //    WindowManager::show_window(resize_panel);
  173.  
  174.     moveTo(1);
  175.     mouseShowCursor();
  176.     }
  177. //////////////////////////
  178.